﻿using System;
using System.Web.Mvc;
using Reece.Open.Mvc.Two.Factories;
using Reece.Open.Objects;

namespace Reece.Open.Mvc.Two.Extenders
{
    public class TopMenu : IDisposable
    {
        private ViewContext _view;
        private INestedMenu _menu;

        public TopMenu(ViewContext viewContext, string id, string css = "dropmenu", bool renderInitScript = false)
        {
            _view = viewContext;
            _menu = MenuFactory.GetMenuContainer(MenuFactory.ContainerType.MainMenu, id, css, renderInitScript);
            _view.Writer.WriteLine(_menu.StartMenu());
        }

        public void Dispose()
        {
            _view.Writer.WriteLine(_menu.FinishMenu());
        }
    }
}